<template>
	<view>
		<view class="families" v-for="(item,index) in memberNameArray" :key="index"
			@click="switchFamilies(item.memberName,index)">
			<view class="families_name">{{item.memberName}}</view>
			<view class="families_name">{{item.uniqueCode}}</view>
			<view class="families_name families_man" v-if="item.memberName==memberName">
				<li></li>当前老人
			</view>
			<view v-if="item.memberName!=memberName">

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				memberName: uni.getStorageSync('memberName'),
				memberNameArray: [],
				id: uni.getStorageSync('relationId'),
			}
		},
		onLoad() {
			this.families();
		},
		methods: {
			families() {
				let memberNameArray = uni.getStorageSync('membersArray');
				this.memberNameArray = memberNameArray
				// console.log('遍历的数组数据: ' + JSON.stringify(this.memberNameArray));
			},
			switchFamilies(memberName, index) {
				uni.setStorageSync('memberName', memberName)
				this.memberName = memberName;
				let members = this.memberNameArray;
				// console.log('点击的下标：' + index);
				// console.log('members[i].id', members[index].id);
				uni.setStorageSync('id', members[index].id)
				uni.setStorageSync('uniqueCode', members[index].uniqueCode)
				uni.setStorageSync('memberName', members[index].memberName)
				uni.setStorageSync('memberTypeText', members[index].memberTypeText)
				uni.setStorageSync('genderText', members[index].genderText)
				uni.setStorageSync('idCard', members[index].idCard)
				uni.setStorageSync('account', members[index].account)
				// for (let i in members) { //把关联对象遍历
				// }
				uni.switchTab({
					url: '/pages/user/index'
				});
			}
		}
	}
</script>

<style scoped lang="less">
	.families {
		background: #FFFFFF;
		width: 97%;
		height: 10vh;
		margin: 2% 0 0 2%;
		border-radius: 10px;
		display: flex;
	}

	.families .families_name {
		flex: 2;
		line-height: 10vh;
		margin-left: 2%;
	}

	.families_man {
		display: flex;

		li {
			// width: 10px;
			font-size: 20px;
			color: #8bcc40;
		}
	}
</style>
